# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//bazel:pl_build_system.bzl", "pl_go_test")

go_library(
    name = "k8smeta",
    srcs = [
        "k8s_metadata_controller.go",
        "k8s_metadata_handler.go",
        "k8s_metadata_store.go",
        "k8s_metadata_utils.go",
        "metadata_topic_listener.go",
    ],
    importpath = "px.dev/pixie/src/vizier/services/metadata/controllers/k8smeta",
    visibility = ["//src/vizier:__subpackages__"],
    deps = [
        "//src/shared/cvmsgspb:cvmsgs_pl_go_proto",
        "//src/shared/k8s",
        "//src/shared/k8s/metadatapb:metadata_pl_go_proto",
        "//src/vizier/messages/messagespb:messages_pl_go_proto",
        "//src/vizier/services/metadata/storepb:store_pl_go_proto",
        "//src/vizier/utils/datastore",
        "//src/vizier/utils/messagebus",
        "@com_github_cenkalti_backoff_v4//:backoff",
        "@com_github_evilsuperstars_go_cidrman//:go-cidrman",
        "@com_github_gogo_protobuf//proto",
        "@com_github_gogo_protobuf//types",
        "@com_github_nats_io_nats_go//:nats_go",
        "@com_github_sirupsen_logrus//:logrus",
        "@io_k8s_api//apps/v1:apps",
        "@io_k8s_api//core/v1:core",
        "@io_k8s_apimachinery//pkg/labels",
        "@io_k8s_apimachinery//pkg/watch",
        "@io_k8s_client_go//informers",
        "@io_k8s_client_go//kubernetes",
        "@io_k8s_client_go//rest",
        "@io_k8s_client_go//tools/cache",
    ],
)

pl_go_test(
    name = "k8smeta_test",
    srcs = [
        "k8s_metadata_controller_test.go",
        "k8s_metadata_handler_test.go",
        "k8s_metadata_store_test.go",
        "metadata_topic_listener_test.go",
    ],
    embed = [":k8smeta"],
    deps = [
        "//src/shared/k8s/metadatapb:metadata_pl_go_proto",
        "//src/utils/testingutils",
        "//src/vizier/messages/messagespb:messages_pl_go_proto",
        "//src/vizier/services/metadata/controllers/testutils",
        "//src/vizier/services/metadata/storepb:store_pl_go_proto",
        "//src/vizier/utils/datastore/pebbledb",
        "@com_github_cockroachdb_pebble//:pebble",
        "@com_github_cockroachdb_pebble//vfs",
        "@com_github_gogo_protobuf//proto",
        "@com_github_nats_io_nats_go//:nats_go",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@io_k8s_api//apps/v1:apps",
        "@io_k8s_api//core/v1:core",
        "@io_k8s_apimachinery//pkg/apis/meta/v1:meta",
        "@io_k8s_apimachinery//pkg/util/intstr",
        "@io_k8s_apimachinery//pkg/watch",
        "@io_k8s_client_go//kubernetes",
        "@io_k8s_client_go//kubernetes/fake",
        "@io_k8s_client_go//testing",
    ],
)
